﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.Library;
using System.Data;
using IHISCETeim.BLL;

namespace IHISCETeim.Web.MachineSys.SAPModel
{
    public partial class SAPBorrowList : EasyUIPageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "SAPBorrowList";
            }
        }


        #region 属性 (查询条件)
        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "BrwID" : base.orderField;
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "DESC" : base.orderDirection;
            }
        }


        protected override string SQLSort
        {
            get
            {
                return (orderField + " " + orderDirection);
            }
        }

        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string DocNum
        {
            get
            {
                return GetRequestValue<string>("DocNum", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string ItemCode
        {
            get
            {
                return GetRequestValue<string>("ItemCode", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string Dscription
        {
            get
            {
                return GetRequestValue<string>("Dscription", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string JieJianBuMen
        {
            get
            {
                return GetRequestValue<string>("JieJianBuMen", "");
            }
        }

        public string showtype
        {
            get {
                return GetRequestValue<string>("showtype", "1");
            }
        }
        protected string GetSql()
        {
            string sqlwhere = QueryFiledHelper.GetSqlWhere(this);
            if (showtype == "1")
            {
                sqlwhere += ((string.IsNullOrEmpty(sqlwhere) ? " " : " and ") + " ReturnQuantity <> quantity");
                
            }

            return sqlwhere;
        }

        protected override string query()
        {
            DataTable dts = SAPBorrowController.SAPBorrow_GetPagination(GetSql(), pageNum, numPerPage, SQLSort, ref TotalCount);

            return ToDataGridJson(dts, TotalCount, null).ToString();
        }


        #endregion
    }
}